﻿using log4net;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;
using Timesheet.Data.Infrastructure;
using Timesheet.Data.Repository;
using Timesheet.Domain;

namespace Timesheet.Service
{
    public class TeamDetailService : ITeamDetailService
    {
        private readonly ITeamDetailRepository _Repository;
        private readonly IUnitOfWork _UnitOfWork;
        public ILog Logger { get; private set; }

        public TeamDetailService(ITeamDetailRepository TeamDetailRepository,IUnitOfWork unitOfWork)
        {
            this._Repository = TeamDetailRepository;
            this._UnitOfWork = unitOfWork;
        }


        #region ITeamDetailService Members

        public IList<TeamDetail> GetTeamDetails()
        {
            return this._Repository.GetAll().ToList();
        }

        public bool CheckExist(TeamDetail entity)
        {
            throw new NotImplementedException();
        }
      
        public void Add(TeamDetail entity)
        {
            this._Repository.Add(entity);
        }

        public void Update(TeamDetail entity)
        {
            var Updateentity = _Repository.GetById(entity.Id);
            Updateentity.Active = entity.Active;
            Updateentity.EmployerID = entity.EmployerID;
            Updateentity.TeamID = entity.TeamID;
            this._Repository.Update(Updateentity);
        }

        public void Delete(TeamDetail entity)
        {
            var Updateentity = _Repository.GetById(entity.Id);
            this._Repository.Delete(Updateentity);
        }             
      
        public IList<TeamDetail> GetTeamDetails(long teamID)
        {
            return _Repository.GetQuery().Where(x => x.TeamID == teamID).ToList();
        }

        #endregion
    }
}
